<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php')
);

return [
    'id' => 'api',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'controllerNamespace' => 'api\controllers',
    'components' => [
        'request' => [
          'parsers' => [
            'application/json' => 'yii\web\JsonParser',
          ]
        ],
      'user' => [
        'identityClass' => 'api\models\User',
        'enableAutoLogin' => true,
        'enableSession' => false,
        'loginUrl'=>null
      ],
      'log' => [
          'traceLevel' => YII_DEBUG ? 3 : 0,
          'targets' => [
              [
                  'class' => 'yii\log\FileTarget',
                  'levels' => ['error', 'warning'],
              ],
          ],
      ],

//      'urlManager' => [
//        'enablePrettyUrl' => true,
//        'enableStrictParsing' => true,
//        'showScriptName' => false,
//        'rules' => [
//          ['class' => 'yii\rest\UrlRule', 'controller' => 'user'],
//        ],
//      ],


    'urlManager' => [
      'enablePrettyUrl' => true,
      'showScriptName' => false,
      'enableStrictParsing' => true,
      'rules' => [
        [
          'class' => 'yii\rest\UrlRule',
          'controller' => ['user','news'],
          'extraPatterns' => [
            'POST login' => 'login',
            //'GET p' => 'p',
            //'GET us' => 'us',
          ],
          'pluralize'=>false,
        ],
      ],
    ],

    ],
  'params' => $params,
];
